import request from './index'

export const carouselAPI = {
  // 获取轮播图列表
  getList: (params) => {
    return request.get('/banners', { params })
  },

  // 获取轮播图详情
  getDetail: (id) => {
    return request.get(`/banners/${id}`)
  },

  // 创建轮播图
  create: (data) => {
    return request.post('/banners', data)
  },

  // 更新轮播图
  update: (id, data) => {
    return request.put(`/banners/${id}`, data)
  },

  // 删除轮播图
  delete: (id) => {
    return request.delete(`/banners/${id}`)
  },

  // 启用轮播图
  enable: (id) => {
    return request.put(`/banners/${id}/enable`)
  },

  // 禁用轮播图
  disable: (id) => {
    return request.put(`/banners/${id}/disable`)
  },

  // 上传轮播图图片
  uploadImage: (formData) => {
    return request.post('/banners/upload', formData, {
      headers: {
        'Content-Type': 'multipart/form-data'
      }
    })
  },

  // 获取启用的轮播图列表
  getActiveList: () => {
    return request.get('/banners/active')
  },

  // 批量更新轮播图排序
  updateSort: (data) => {
    return request.put('/banners/sort', data)
  }
}